Syllabus

https://www.youtube.com/watch?v=U1HbB0ATZ_A

Conditional Probability, Bayes Theorem and Total Probabilites

Likelihood

Conjugate priors

In Bayesian probability theory, if the posterior distribution p(θ | x) is in the same probability distribution family as the prior probability distribution p(θ), the prior and posterior are then called conjugate distributions, and the prior is called a conjugate prior for the likelihood function p(x | θ).

https://www.youtube.com/watch?v=7mZksQ24MlI

In this case, a Normal prior, turns to a Normal posterior, and a prior Beta turns to a posterior Beta.

Posterior Distribution

Predictive Distributions

Credibility Interval

https://www.youtube.com/watch?v=vJ-NqIgYJyY

Poisson - Gamma

Reference: (Wolpert, n.d.)

Examples

wait

Proper and Improper distributions

Distributions

Poisson

https://bookdown.org/kevin_davisross/bayesian-reasoning-and-methods/poisson.html

A discrete random variable Y has a Poisson distribution with parameter \(\theta>0\) if its probability mass function satisfies \[ \begin{align*} f(y|\theta) & = \frac{e^{-\theta}\theta^y}{y!}, \quad y=0,1,2,\ldots \end{align*} \] If \(Y\) has a \(Poisson(\theta)\) distribution then

\[ \begin{align*} E(Y) & = \theta\\ Var(Y) & = \theta \end{align*} \]

Gamma

#### Expected Mean, Variance

\[E[\theta | x] = \frac{\alpha}{ \beta}\]

\[Var[\theta | x] = \frac{\alpha}{ \beta^2}\]

Examples

Examples of Gamma:

Exercises:

Exercices

References - Class Exercices

Ex4

Ex5

Ex6

Solutions:

Ex7

Identify Prior Distribution

Ex6 - A

Question from Exercice 6 of classes.

If we look at the distribution of gamma, we can conclude it’s a gamma distribution with parameters: \[\theta \sim \Gamma (\mu h, h)\]

a posteriori Distribution

Ex6 - B

Question from Exercice 6 of classes.

See:
* Poisson-Gamma conjugate

If \(\mu = h = 2\), \(\sum_{i=1}^{n} x_i = 18\) and \(n=6\) then the \(a posteriori\) distribution of \(\theta\) is

mu_prior = 2
h_prior = 2

alpha_prior = mu_prior*h_prior
beta_prior = h_prior

sum_xi_1 = 18
n_1 = 6

alpha_posterior = alpha_prior + sum_xi_1
beta_posterior = beta_prior + n_1

cat("Alpha Posterior:", alpha_posterior, "\nBeta Posterior", beta_posterior)
## Alpha Posterior: 22 
## Beta Posterior 8

The a posteriori distribution is a \(Gamma(22,8)\)

Ex7 - A

See:
* Poisson-Gamma conjugate

The a priori distribution is a \(Gamma(2, 1)\) for \(\theta_1\) and \(\theta_2\).

Mean, variance, etc

Ex6 - C

Question from Exercice 6 of classes.

e_mean = 22 / 8

e_var = 22 / ((8)**2) ## 22/64

cat("Expected Mean:", e_mean, "\nExpected Variance", e_var)
## Expected Mean: 2.75 
## Expected Variance 0.34375

Credible interval

Ex6 - D

See:
* Credibility Intervals

So here, to calculate the credibility interval, we do the following

alpha = 22; beta = 8  # parameters of the posterior distribution (Gamma)

qinf_gamma = qgamma(p=0.025,shape=alpha,rate=beta,lower.tail=T)
qsup_gamma = qgamma(p=0.025,shape=alpha,rate=beta,lower.tail=F)
cat("Interval: [",qsup_gamma,",",qinf_gamma,"]")
## Interval: [ 4.012591 , 1.72341 ]
## Alternatively with Gamma
qsup2_gamma = qgamma(p=0.975,shape=alpha,rate=beta,lower.tail=T)
cat("Interval: [",qsup2_gamma,",",qinf_gamma,"]")
## Interval: [ 4.012591 , 1.72341 ]

Visually this means:

TODO: Interpretation of this interval

References

Wolpert, Robert L. n.d. “Confidence & Credible Interval Estimates.”